<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.fick.hibernate.model.*,java.text.SimpleDateFormat"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@page import="java.util.Date,com.fick.util.UpPic"%>
<%@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="FCK"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>河南省公安厅</title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/check.js"></script>
<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js" defer="defer"></script>
<script type="text/javascript">
<!--
			    function CheckForm() {
					if(document.form1.title.value=="")
					{
						alert("标题不能为空");
						document.form1.title.focus();
						return false;
					}
					if(document.form1.content.value=="")
					{
						alert("内容不能为空");
						document.form1.content.focus();
						return false;
					}
					if(document.form1.width.value=="")
					{
						alert("宽度不能为空");
						document.form1.width.focus();
						return false;
					}
					if(isNaN(document.form1.width.value))
					{
						alert("宽度只能为数字");
						return false;
					}
					if(document.form1.height.value=="")
					{
						alert("高度不能为空");
						document.form1.height.focus();
						return false;
					}
					if(isNaN(document.form1.height.value))
					{
						alert("高度只能为数字");
						return false;
					}
				}
//-->
</script>
</head>

<body>
	<%
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
	 %>
		
	<%
		//完成删除操作
		if(request.getParameter("del")!=null)
		{
			int id=Integer.parseInt(request.getParameter("id"));
			BaseHibernateDAO dao=new BaseHibernateDAO();
			dao.getSession().beginTransaction();
			dao.getSession().createQuery("delete PopWindow where id="+id).executeUpdate();
			dao.getSession().beginTransaction().commit();
			out.print("<script>window.location.href=\'popWindowList.jsp\'</script>");
			return;
		}
	%>
	
	<%
		PopWindow window=null;
		if(request.getParameter("id")!=null && !request.getParameter("id").equals(""))
		{
			BaseHibernateDAO dao=new BaseHibernateDAO();
			window=(PopWindow)dao.findBySql(PopWindow.class," where id="+request.getParameter("id")).get(0);
		}
	%>
<table width="100%"  height="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100%" align="center" valign="top" background="images/main_bj.gif" bgcolor="#FBFCFD"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="23" align="left" valign="middle" background="images/main_top.gif"><table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="20" height="23">&nbsp;</td>
            <td width="400" height="23" align="left" valign="middle" class="ts_lmdh2">添加弹出窗口</td>
          </tr>
        </table></td>
      </tr>
    </table>
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="20"></td>
        </tr>
      </table>
	<form name="form1" id="form1" action="addPopwindowAction.jsp"  method="post" onSubmit="return CheckForm()" />
      <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
          <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">窗口标题：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="title" id="title"  size="30" value="<%=window!=null?window.getTitle():"" %>"  type="text" class="ts_box3"/>
		  </td>
        </tr>
        <%
        String content = "";
        if(window != null)
        	content = window.getContent();
         %>
        <tr>
          <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">内　　容：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <textarea cols="50" name="content" rows="5" class="ts_box4"><%=content%>
		  </textarea>
		  </td>
        </tr>
        
	      <tr>
          <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">宽　　度：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
           <input name="width"  id="width" size="30" value="<%=window!=null?window.getWidth():"" %>"  type="text" class="ts_box3" maxlength="4"/>
		  </td>
        </tr>
        <tr>
          <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">高　　度：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="height" id="height" size="30" value="<%=window!=null?window.getHeight():"" %>"  type="text" class="ts_box3" maxlength="4"/>
		  </td>
        </tr>
        <%
        	Date beginTime = new Date();
        	String beginTimestr = sdf.format(beginTime); 
        	Date endTime = new Date();
        	String endTimestr = sdf.format(endTime);
        	if(window != null){
        		beginTimestr = window.getBeginTime().toString();
        		endTimestr = window.getEndTime().toString();
        	}
         %>
        <tr>
          <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">开始时间：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="beginTime" id="beginTime" class="Wdate"
				type="text" size="30" value="<%=beginTimestr %>"
				onClick="WdatePicker({skin:'default',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
		  </td>
        </tr>        
        <tr>
          <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">结束时间：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="endTime" id="endTime" class="Wdate"
				type="text" size="30" value="<%=endTimestr %>"
				onClick="WdatePicker({skin:'default',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
		  </td>
        </tr>
        <tr>
          <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">URL：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="url" id="url" size="30" value="<%=window!=null?window.getUrl()!=null?window.getUrl():"":"" %>"  type="text" class="ts_box3" />
		  </td>
        </tr>
        <!--
        <tr> 
          <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">是否显示：</td>
           <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input type="radio" name="isShow" value="1" <%//if(window!=null){out.print((window.getIsShow().equals("1"))?"checked":"");}else{out.print("checked");}%>>是
		  <input type="radio" name="isShow" value="0"<%//if(window!=null){out.print((window.getIsShow().equals("0"))?"checked":"");}else{out.print("checked");}%>>否
		  </td>
        </tr>
        -->
          <tr>
          <td height="30" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF">
          <%if(request.getParameter("id")!=null){%>
          <input type="hidden" name="id" value="<%=request.getParameter("id")%>">
          <%}%>
		  <input type="submit" name="Submit" value="提交">
		  <input  type="button" value="返回" onClick="javascript:history.go(-1);">
		  </td>
        </tr>
      </table>
	</form>	  
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="45" align="center" valign="middle">&nbsp;</td>
        </tr>
      </table>
      </td>
  </tr>
</table>
</body>
</html>
